﻿using MediatR;
using T_Material.API.Application.Commands.PurchaseCommand;
using T_Material.Infrastructure.Interface;

namespace T_Material.API.Application.CommandHandlers.PurchaseHandler
{
    public class PurchaseDeleteCommandHandler : IRequestHandler<PurchaseDeleteCommand, int>
    {
        private readonly IPurchaseRepository purchaseRepository;
        public PurchaseDeleteCommandHandler(IPurchaseRepository purchaseRepository)
        {
            this.purchaseRepository = purchaseRepository;
        }

        public async Task<int> Handle(PurchaseDeleteCommand request, CancellationToken cancellationToken)
        {
                var info = await purchaseRepository.GetModelAs(request.Id);
                info.IsDel = true;
                return await purchaseRepository.Update(info);
        }
    }
}
